package com.bida.core.mongo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.mongodb.core.MongoTemplate;

/**
 * This is the MongoDB DAO class for the "default" MongoDB connection. For
 * programmers (and code) that doesn't need to care about our multi-mongodb
 * scheme, they can simply derive from this class and that would be it.
 * 
 * The only thing we need to do is to auto-wire a "MongoTemplate" class so that
 * our base class knows which MongoDB to connect to. There are multiple instance
 * of this class, each with a different "qualifier", so we should specify the
 * qualifier here.
 * 
 * For connection to other instances, please refer to MongodbPluginDao and
 * MongodDbUserCenterDao for examples.
 * 
 * @param <T>
 */
public abstract class MongodbDao<T> extends BaseMongodbDao<T> {

    /**
     * The "Qualifier" below is a bit redundant, but we just want to make this
     * class look exactly like the others It is also the same as the class name,
     * as SpringBook
     * 
     * @EnableAutoConfiguration needs a default mongoTemplate.
     * @param mongoTemplate
     *            inject bean which name is 'mongoTemplate'
     */
    @Autowired
    public void setMongoTemplate(@Qualifier("mongoTemplate") MongoTemplate mongoTemplate) {
        super.setMongoTemplate(mongoTemplate);
    }

}
